﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using EzyGoEzySystem.Services;

namespace EzyGoEzySystem.Models
{
    public class PaymentJournalEntry
    {
        #region Scalar Properties

        [Key]
        public int ID { get; set; }

        [Required]
        public double Amount { get; set; }

        [Required]
        public string Invoice { get; set; }

        [Required]
        public int AccountID { get; set; }

        public DateTime? PaymentDate { get; set; }

        [Required]
        public string PaymentStatus { get; set; }

        #endregion

        #region Navigation Properties

        // one travel journal entry belongs to one account
        public virtual Account Account { get; set; }

        #endregion

        #region Static Methods

        //public static PaymentJournalEntry GetPaymentJournalEntry(string invoice)
        //{
        //    using (var dbContext = new EzyGoEzyDBContext())
        //    {
        //        var entries = from entry in dbContext.PaymentJournalEntries
        //                      where entry.Invoice == invoice
        //                      select entry;
        //        return entries.First();
        //    }
        //}

        //public static PaymentJournalEntry GetPaymentJournalEntry(string invoice, EzyGoEzyDBContext dbContext)
        //{
        //    var entries = from entry in dbContext.PaymentJournalEntries
        //                  where entry.Invoice == invoice
        //                  select entry;
        //    return entries.First();
        //}
        #endregion
    }
}